package com.tjsinfo.tjsoa.fileDocument.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.json.JSONArray;
import org.json.JSONObject;

import com.tjsinfo.tjsoa.fileDocument.bo.IFileDocumentUserBo;
import com.tjsinfo.tjsoa.fileDocument.vo.FileDocumentUser;

public class SelectUserRolesAction extends Action{
	private IFileDocumentUserBo fileDocumentUserBo;

	public IFileDocumentUserBo getFileDocumentUserBo() {
		return fileDocumentUserBo;
	}

	public void setFileDocumentUserBo(IFileDocumentUserBo fileDocumentUserBo) {
		this.fileDocumentUserBo = fileDocumentUserBo;
	}

	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		// TODO Auto-generated method stub
	    String groupid  = request.getParameter("groupid");
		List<FileDocumentUser> list = fileDocumentUserBo.selectGroupUser(groupid);
		JSONArray array = new JSONArray();
		for (FileDocumentUser fileDocumentUser : list) {
			JSONObject object = new JSONObject();
			object.put("userId", fileDocumentUser.getTjsUser().getUserId());
			object.put("userName", fileDocumentUser.getTjsUser().getUserName());
			object.put("uuid", fileDocumentUser.getTjsUser().getUuid());
			array.put(object);
		}
		response.getWriter().print(array);
		return null;
	}
	
	
}
